package com.ai.wxy.spring.web.util;

import com.ai.spring.common.util.Assert;

/**
 * 常量
 *
 * @author 石头
 * @Date 2019/11/15
 * @Version 1.0
 **/
public final class Constans {
    /**服务配置接口ID*/
    public static final String SVC_CONF_ID = "servicesConfig";
    /**服务配置接口方法*/
    public static final String SVC_CONF_METHOD = "getServiceConfByReqId";
    /**size 单位为KB*/
    public static final String SIZE_KB = "KB";
    /**size 单位为MB*/
    public static final String SIZE_MB = "MB";

    public static long parseSize(String size){
        Assert.notEmpty(size,"Size must not be empty");

        if (size.endsWith(SIZE_KB)){
            return Long.valueOf(size.substring(0,size.length() - 2)) * 1024;
        }
        if (size.endsWith(SIZE_MB)){
            return Long.valueOf(size.substring(0,size.length() - 2)) * 1024 * 1024;
        }
        return Long.valueOf(size);
    }
}
